package com.android.luhnchecking.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

public class Database {
	private static Database database;

	private DbHelper mHelper;
	private SQLiteDatabase sqLiteDatabase;

	private Database(Context context) {
		mHelper = new DbHelper(context);
	}

	public static Database getInstance(Context context) {
		if (database == null) {
			database = new Database(context);
		}
		return database;
	}

	public SQLiteDatabase getReadable() {
		sqLiteDatabase = mHelper.getReadableDatabase();
		return sqLiteDatabase;
	}

	public SQLiteDatabase getWritable() {
		sqLiteDatabase = mHelper.getWritableDatabase();
		return sqLiteDatabase;
	}

	public void close() {
		sqLiteDatabase.close();
	}
}
